import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: '登录',
    component: () => import('@/views/sign/signIn.vue'),
  },
  {
    path: '/register',
    name: '注册',
    component: () => import('@/views/sign/signUp.vue'),
  },

  {
    path: '/',
    component: () => import('@/views/backstage/h-nav.vue'),

    children: [
      // 首页
      {
        path: '/home',
        component: () => import('@/views/backstage/home/home.vue'),
        name: '首页',
        meta: {
          title: '首页'
        }
      },
      {
        path: '/match',
        component: () => import('@/views/backstage/match/match.vue'),
        name: '所有赛事',
        meta: {
          title: '所有赛事'
        }
      },
      {
        path: '/match',
        component: () => import('@/views/backstage/v-nav.vue'),

        children: [// 具体赛事 导航
          {
            path: '/match/matchMsg',
            component: () => import('@/views/backstage/match/matchMsg.vue'),
            name: '赛事详情',
            meta: {
              title: '赛事详情'
            }
          },
          // 赛事发布
          {
            path: '/match/matchPut',
            component: () => import('@/views/backstage/match/matchPut.vue'),
            name: '赛事发布',
            meta: {
              title: '赛事发布'
            }
          },
          // 赛事数据 ==》 基本数据 ==》轨迹发布 打卡点信息关门时间 赛事天气  //// =>强装清单
          {
            path: '/match/matchData/siteAll',
            component: () => import('@/views/backstage/match/matchData/siteAll.vue'),
            name: '站点集合',
            meta: {
              title: '站点集合'
            }
          },
          {
            path: '/match/matchData/basicMsg',
            component: () => import('@/views/backstage/match/matchData/basicMsg.vue'),
            name: '组别信息',
            meta: {
              title: '组别信息'
            }
          },
          {
            path: '/match/matchData/trackRoute',
            component: () => import('@/views/backstage/match/matchData/trackRoute.vue'),
            name: '轨迹路线',
            meta: {
              title: '轨迹路线'
            }
          },
          {
            path: '/match/matchData/weather',
            component: () => import('@/views/backstage/match/matchData/weather.vue'),
            name: '赛事天气',
            meta: {
              title: '赛事天气'
            }
          },
          {
            path: '/match/matchData/menu',
            component: () => import('@/views/backstage/match/matchData/menu.vue'),
            name: '菜单管理',
            meta: {
              title: '菜单管理'
            }
          },
          {
            path: '/match/matchData/fitOut',
            component: () => import('@/views/backstage/match/matchData/fitOut.vue'),
            name: '强装清单',
            meta: {
              title: '强装清单'
            }
          },
          {
            path: '/match/matchData/takeThings',
            component: () => import('@/views/backstage/match/matchData/takeThings.vue'),
            name: '领物信息',
            meta: {
              title: '领物信息'
            }
          },
          {
            path: '/match/matchData/traffic',
            component: () => import('@/views/backstage/match/matchData/traffic.vue'),
            name: '交通信息',
            meta: {
              title: '交通信息'
            }
          },
          {
            path: '/match/matchData/hotel',
            component: () => import('@/views/backstage/match/matchData/hotel.vue'),
            name: '酒店信息',
            meta: {
              title: '酒店信息'
            }
          },
          // 报名管理 
          // 报名表单
          {
            path: '/match/sign/signFrom',
            component: () => import('@/views/backstage/sign/signFrom.vue'),
            name: '报名表单',
            meta: {
              title: '报名表单'
            }
          },
          {
            path: '/match/sign/signPrice',
            component: () => import('@/views/backstage/sign/signPrice.vue'),
            name: '报名价格设置',
            meta: {
              title: '报名价格设置'
            }
          },
          {
            path: '/match/sign/entryNumSet',
            component: () => import('@/views/backstage/sign/entryNumSet.vue'),
            name: '号码牌配置',
            meta: {
              title: '号码牌配置'
            }
          },
          {
            path: '/match/sign/refundRule',
            component: () => import('@/views/backstage/sign/refundRule.vue'),
            name: '退费设置',
            meta: {
              title: '退费设置'
            }
          },
          {
            path: '/match/sign/playersList',
            component: () => import('@/views/backstage/sign/playersList.vue'),
            name: '选手名单',
            meta: {
              title: '选手名单'
            }
          },
          // 赛事公告
          {
            path: '/match/matchNotice',
            component: () => import('@/views/backstage/matchNotice/matchNotice.vue'),
            name: '赛事公告',
            meta: {
              title: '赛事公告'
            }
          },
          // 赛事执行
          {
            path: '/match/carry/live',
            component: () => import('@/views/backstage/carry/live/live.vue'),
            name: '赛事live',
            meta: {
              title: '赛事live'
            }
          },
          {
            path: '/match/carry/workPer',
            component: () => import('@/views/backstage/carry/live/workPer.vue'),
            name: '工作人员',
            meta: {
              title: '工作人员'
            }
          },
          // 赛后服务
          {
            path: '/match/end/grade',
            component: () => import('@/views/backstage/endServe/grade.vue'),
            name: '成绩统计',
            meta: {
              title: '成绩统计'
            }
          },
          // 活动成绩统计
          {
            path: '/match/end/actGrade',
            component: () => import('@/views/backstage/endServe/actGrade.vue'),
            name: '活动成绩统计',
            meta: {
              title: '活动成绩统计'
            }
          },
          {
            path: '/match/end/cer',
            component: () => import('@/views/backstage/endServe/certificate.vue'),
            name: '完赛证书',
            meta: {
              title: '完赛证书'
            }
          },
          {
            path: '/match/end/actcer',
            component: () => import('@/views/backstage/endServe/actCerSet.vue'),
            name: '活动证书',
            meta: {
              title: '活动证书'
            }
          },
          {
            path: '/match/end/album',
            component: () => import('@/views/backstage/endServe/album.vue'),
            name: '赛事相册',
            meta: {
              title: '赛事相册'
            }
          },
          // 营销推广 竞猜抽奖 banner设置
          {
            path: '/match/extend/guess',
            component: () => import('@/views/backstage/extend/guess/guess.vue'),
            name: '竞猜设置',
            meta: {
              title: '竞猜设置'
            }
          },
          {
            path: '/match/extend/guess/luck',
            component: () => import('@/views/backstage/extend/luck/ldAdd.vue'),
            name: '抽奖设置',
            meta: {
              title: '抽奖设置'
            }
          },
          {
            path: '/match/extend/guess/ldper',
            component: () => import('@/views/backstage/extend/luck/luckPer.vue'),
            name: '抽奖人员名单',
            meta: {
              title: '抽奖人员名单'
            }
          },
          {
            path: '/match/extend/guess/ldRecord',
            component: () => import('@/views/backstage/extend/luck/ldRecord.vue'),
            name: '抽奖记录',
            meta: {
              title: '抽奖记录'
            }
          },
          {
            path: '/match/extend/banner',
            component: () => import('@/views/backstage/extend/banner.vue'),
            name: 'banner',
            meta: {
              title: 'banner'
            }
          },
          // 报名款管理
          {
            path: '/match/money/am_money',
            component: () => import('@/views/backstage/money/am_money.vue'),
            name: '报名款管理',
            meta: {
              title: '报名款管理'
            }
          },
          // 留言管理
          {
            path: '/match/feedBack',
            component: () => import('@/views/backstage/feedBack.vue'),
            name: '留言管理',
            meta: {
              title: '留言管理'
            }
          },
        ]
      },
      // 营销推广 ==》 需设置权限可见 ==》 主针对热门赛事 热门活动 今日推荐 公司账号或内部人员可见 此推广并不是针对单个赛事
      {
        path: '/Marketing',
        component: () => import('@/views/backstage/Marketing/Marketing.vue'),
        children: [
          {
            path: '/Marketing/banner',
            component: () => import('@/views/backstage/Marketing/banner.vue'),
            name: 'banner设置',
            meta: {
              title: 'banner设置'
            }
          },
          {
            path: '/Marketing/hot',
            component: () => import('@/views/backstage/Marketing/hot.vue'),
            name: '热门设置',
            meta: {
              title: '热门设置'
            }
          },
        ]
      },
      // 商品管理
      {
        path: '/goods',
        component: () => import('@/views/backstage/goods/goods.vue'),
        name: '商品管理',
        meta: {
          title: '商品管理'
        }
      },
      // 全局文章管理
      {
        path: '/article',
        component: () => import('@/views/backstage/article/article.vue'),
        name: '文章管理',
        meta: {
          title: '文章管理'
        }
      },

      {
        path: '/luck',
        component: () => import('@/views/backstage/extend/luck/globalLuck.vue'),
        name: '抽奖设置',
        meta: {
          title: '抽奖设置'
        }
      },
      // 所有报名款 管理
      {
        path: '/money',
        component: () => import('@/views/backstage/money/all_money.vue'),
        name: '报名款统计',
        meta: {
          title: '报名款统计'
        }
      },
      // 合作伙伴
      {
        path: '/partner',
        component: () => import('@/views/backstage/other/partner.vue'),
        name: '合作伙伴',
        meta: {
          title: '合作伙伴'
        }
      },
      // 账号资料 
      {
        path: '/account',
        component: () => import('@/views/backstage/other/account.vue'),
        name: '账号资料',
        meta: {
          title: '账号资料'
        }
      },
      // 用户成绩上传管理
      {
        path: '/gradeU',
        component: () => import('@/views/backstage/other/gradeU.vue'),
        name: '用户成绩管理',
        meta: {
          title: '用户成绩管理'
        }
      },

    ]
  },
  {
    path: '/temp',
    component: () => import('@/components/temp.vue'),
  },
  {
    path: '/404',
    component: resolve => require(['@/views/404.vue'], resolve)
  },
  {
    path: '*',
    redirect: '/404'
  }
]
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'hash',
  // history hash
  base: process.env.BASE_URL,
  routes,
  // 切换路由后滚动条置顶
  scrollBehavior() {
    return {
      x: 0,
      y: 0
    }
  }
})
export default router
